package com.ccys.cms.controller.administrator;

import com.ccys.cms.service.administrator.TblDeliveryCountryLocationWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.administrator.TblDeliveryCountryLocationDTO;
import com.ccys.db.entity.TblDeliveryCountryLocation;
import com.ccys.db.vo.administrator.TblDeliveryCountryLocationWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "系统设置-delivery timeslots 快递时段-location-based")
@RequestMapping("administrator")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT}) // 开启跨域访问允许
@SuppressWarnings("unchecked")
public class DeliveryCountryLocationWebController {

    @Autowired
    private TblDeliveryCountryLocationWebService tblDeliveryCountryLocationWebService;

    @GetMapping("deliveryCountryLocation")
    @ApiOperation("获取列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dcId", value = "关联对象ID", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclCity", value = "dclCity", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclDistrict", value = "dclDistrict", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclOtherDivision", value = "dclOtherDivision", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclUnitType", value = "时间类型:1hours 2:days", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "orderByStr", value = "排序字段（后端返回的字段  asc升序，desc 降序,加上end后缀。示例（createdOn降序排 则传值 createdOn descend））",paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = TblDeliveryCountryLocationWebVO.class)
    })
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryCountryLocationDTO dto) {
        return this.tblDeliveryCountryLocationWebService.listObjectsCms(request, response, dto);
    }

    @GetMapping("deliveryCountryLocation/city")
    @ApiOperation("获取快递的下拉city数据列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dcCountryId", value = "国家ID", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = String.class)
    })
    public ResponseResult listCity(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryCountryLocationDTO dto) {
        return this.tblDeliveryCountryLocationWebService.listCity(request, response, dto);
    }

    @GetMapping("deliveryCountryLocation/district")
    @ApiOperation("获取快递的下拉district数据列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dcCountryId", value = "国家ID", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = String.class)
    })
    public ResponseResult listDistrict(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryCountryLocationDTO dto) {
        return this.tblDeliveryCountryLocationWebService.listDistrict(request, response, dto);
    }

    @GetMapping("deliveryCountryLocation/otherDivision")
    @ApiOperation("获取快递的下拉OtherDivision数据列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dcCountryId", value = "国家ID", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = String.class)
    })
    public ResponseResult listOtherDivision(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryCountryLocationDTO dto) {
        return this.tblDeliveryCountryLocationWebService.listOtherDivision(request, response, dto);
    }

    @PostMapping("deliveryCountryLocation")
    @ApiOperation("添加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dcId", value = "dcId", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclRegion", value = "dclRegion", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclCity", value = "dclCity", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclDistrict", value = "dclDistrict", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclOtherDivision", value = "dclOtherDivision", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclMinValue", value = "dclMinValue", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclMaxValue", value = "dclMaxValue", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclUnitType", value = "时间类型:1hours 2:days", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclCanDeliver", value = "dclCanDeliver", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclStatus", value = "dclStatus", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult save(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryCountryLocation entity) {
        entity.setId(null);
        return this.tblDeliveryCountryLocationWebService.change(request, response, entity);
    }


    @PutMapping("deliveryCountryLocation")
    @ApiOperation("编辑")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dcId", value = "dcId", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclRegion", value = "dclRegion", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclCity", value = "dclCity", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclDistrict", value = "dclDistrict", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclOtherDivision", value = "dclOtherDivision", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclMinValue", value = "dclMinValue", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclMaxValue", value = "dclMaxValue", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclUnitType", value = "时间类型:1hours 2:days", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclCanDeliver", value = "dclCanDeliver", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "dclStatus", value = "dclStatus", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblDeliveryCountryLocation entity) {
        Kit.allParamValid(entity, "id");
        return this.tblDeliveryCountryLocationWebService.change(request, response, entity);
    }


    @DeleteMapping("deliveryCountryLocation")
    @ApiOperation("删除")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult delete(HttpServletRequest request, HttpServletResponse response, TblDeliveryCountryLocation dto) {
        Kit.allParamValid(dto, "id");
        return this.tblDeliveryCountryLocationWebService.delete(request, response, dto);
    }

}